package com.huli.controller;
import com.huli.domain.vo.OrderDetailVO;
import com.huli.domain.vo.OrderVerifyVO;
import com.huli.domain.vo.ServiceCompleteVO;
import com.huli.service.OrderInfoService;
import com.huli.util.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("/orderToOk")
public class OrderToOkController {
    @Autowired
    private OrderInfoService orderInfoService;
    //根据订单状态查询完成订单
    @RequestMapping("/YesOrder")
    public Integer NoOrder(){
        return  orderInfoService.updateOrderStatusByYes();
    }

    //根据订单状态查询未派单订单
    @RequestMapping("/NoOrder")
    public int YesOrder(){
        return  orderInfoService.updateOrderStatusByNo();
    }
    //根据订单状态查询未完成的订单
    @RequestMapping("NotOkOrder")
    public int NotOkOrder(){
        return  orderInfoService.updateOrderStatusByNotOk();
    }
    //派单功能实现
    @RequestMapping("orderToGo")
    public int orderToGo(@Param("nurseId") Integer nurseId, @Param("id") Integer id,@Param("messages") String messages){
        return  orderInfoService.updateOrderToGo(nurseId,id,messages);
    }
    //订单详情中的所需耗材
    @RequestMapping("getinfo")
    public Result show(Integer orderId){
        Result show = orderInfoService.show(orderId);
        return show;
    }
    //患者资料
    @RequestMapping("getcase")
    public Result getcase(Integer id){
        Result caseImage = orderInfoService.getcase(id);
        return caseImage;
    }
    //查询订单明细

    @RequestMapping("findByOrderNo")
    public List<OrderDetailVO> findByOrderNo(OrderDetailVO orderInfo){
        List<OrderDetailVO> orderInfoList = orderInfoService.findByOrderNo(orderInfo);
        return orderInfoList;
    }
    //根据订单查询派单情况
    @RequestMapping("findByOrderXq")
    public List<OrderDetailVO> findByOrderXq(OrderDetailVO orderInfo){
        List<OrderDetailVO> orderInfoList = orderInfoService.getOrderDetail(orderInfo);
        return orderInfoList;
    }

    /**
     * 验证订单验证码并开始服务
     * @param verifyVO 验证信息
     * @return 验证结果
     */
    @PostMapping("/verifyAndStart")
    public Result verifyAndStartService(@RequestBody OrderVerifyVO verifyVO) {
        return orderInfoService.verifyAndStartService(verifyVO);
    }

    /**
     * 服务完成确认
     * 
     * @param completeVO 服务完成信息
     * @return 处理结果
     */
    @PostMapping("/complete")
    public Result completeService(@RequestBody ServiceCompleteVO completeVO, @RequestParam("messages") String messages) {
        return orderInfoService.completeService(completeVO,messages);
    }

}
